package caixindemo.colin.com.caixindemo;

import android.os.Bundle;
import android.support.v4.widget.SlidingPaneLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;

import caixindemo.colin.com.caixindemo.adapter.ListRecyclerViewAdapter;
import caixindemo.colin.com.caixindemo.widget.AutoTextView;

import static caixindemo.colin.com.caixindemo.widget.AutoTextView.OnClickScrollContentListener;

public class MainActivity extends AppCompatActivity {
    private AutoTextView auto_text_scroll;
    private SlidingPaneLayout mDrawerLayout;
    private LinearLayout linear_one;
    private LinearLayout linear_two;
    private ListView list_main_show;
    private RecyclerView recycler_view;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        initView();


    }

    private List<AutoTextView.AutoEntry> initData() {
        List<AutoTextView.AutoEntry> entryList = new ArrayList<>();
        AutoTextView.AutoEntry autoEntry = null;
        for (int i = 0; i < 3; i++) {
            autoEntry = new AutoTextView.AutoEntry("你好", "Colin-->>" + String.valueOf(i + 1), "www.baidu.com");
            entryList.add(autoEntry);
        }
        return entryList;
    }

    private void initView() {
        auto_text_scroll = (AutoTextView) this.findViewById(R.id.auto_text_scroll);
        auto_text_scroll.setTextList(initData());
        auto_text_scroll.setOnClickTextContentLitener(new OnClickScrollContentListener() {
            @Override
            public void onClick(String mUrl) {
                Toast.makeText(MainActivity.this, mUrl, Toast.LENGTH_SHORT).show();
            }
        });


        mDrawerLayout = (SlidingPaneLayout) findViewById(R.id.content_main);
        linear_one = (LinearLayout) findViewById(R.id.linear_one);
        linear_two = (LinearLayout) findViewById(R.id.linear_two);
        list_main_show = (ListView) findViewById(R.id.list_main_show);
        list_main_show.setAdapter(new ListRecyclerViewAdapter(this, getList()));
    }

    private List<String> getList() {
        List<String> stringList = new ArrayList<>();
        for (int i = 0; i < 20; i++) {
            stringList.add("Colin-->>" + String.valueOf(i + 1));
        }
        return stringList;
    }


}
